function plotConditionalForecasts(setStru,model,forcStru,forecast,histStru,forecastConditional)
%% III.4 Plot of forecasts with all shocks on and all shocks off 
barlegends={char(sample2date(setStru.dataVec(size(model.data,1)-1))),...
    char(sample2date(setStru.dataVec(end)))};
xaxis=[setStru.dataVec(size(model.data,1)-1); forcStru.forcVec];
xaxis_labels=sample2date(xaxis);
for kk=0:fix(length(xaxis)/4)
    xaxis_labels{4*kk+2}='';
    xaxis_labels{4*kk+3}='';
    xaxis_labels{4*kk+4}='';
end

% if length(xaxis)-4*fix(length(xaxis)/4)>0
%     xaxis_labels(end-(length(xaxis)-4*fix(length(xaxis)/4)):end) = '';
% end

gvec_Revision=zb_plot2forecasts(forecast.allShocksOff,forecast.adjustedForc,['Forecast in ',barlegends{1},' vs ',barlegends{2}],barlegends,xaxis(1:end),forcStru.labels');

flag_noShockForecast=0;
if flag_noShockForecast==1 
    return 
end 

%pos_gdpdef=cellposition('GDP deflator',stanames_base);

%% III.2 Line settings 
barlegends={'Baseline',['Forecast in ',char(sample2date(setStru.dataVec(end-1)))],...
        ['Forecast with shocks realized in ',char(sample2date(setStru.dataVec(end)))] }; 

color_mat=[0 0 0;0.5 0.5 0.5;0 0 0]; 
width_mat=[1     1.5         2    ]; 
style_mat={'-','-','-.'}; 
barlegends=barlegends(2:end);
titfont=11; 

clear hand*; 

%% III.3 Begin plots with groups of forecasts ON
ns = length(forcStru.labels);
gvec_Shockcont=zeros(ns,1);
numGroups=length(histStru.groupnames{1});
nc       =2; 
nr       =ceil((numGroups/nc)+1);
for kk=1:ns
    gvec_Shockcont(kk)=figure;
    tastyRecipe(kk) = figure;
    for jj=1:numGroups
        clear hand1 hand2 hand3;
        handsub=subplot(nr,nc,jj); 
        set(handsub,'LineStyleOrder',style_mat); 
        hand2=plot(xaxis,forecast.allShocksOff(:,kk),'-');
        set(hand2,'color',color_mat(2,:),'LineWidth',width_mat(2)) 
        hold on;
        hand3=plot(xaxis(2:end),forecastConditional{jj}.adjustedForc(1:end,kk),'-.'); 
        set(hand3,'color',color_mat(3,:),'LineWidth',width_mat(3)); 
        hold off
        
        title(histStru.groupnames{1}(jj),'FontSize',titfont)
        limvec=limsaj([forecast.allShocksOff(2:end,kk) forecastConditional{jj}.adjustedForc(1:end,kk)],0.3); 
        axis tight; 
        set(handsub,'box','off')
        xlim([xaxis(1)-0.05 xaxis(end)+0.05]) 
        set(gca,'XTick',xaxis)
        set(gca,'XTickLabel',xaxis_labels)
        %ylim(limvec); 
        hand4=vline(xaxis(2));
        set(hand4,'Color','g','LineWidth',2,'LineStyle','--');
    end
    set(tastyRecipe(kk),'paperPosition', [0.75 0.5 7.5 10]);
    clear hand1 hand2 hand3;
    handsub=subplot(nr,nc,numGroups+1); 
    set(handsub,'LineStyleOrder',style_mat); 
    hand2=plot(xaxis,forecast.allShocksOff(:,kk),'-');
    set(hand2,'color',color_mat(2,:),'LineWidth',width_mat(2)) 
    hold on;
    hand3=plot(xaxis(2:end),forecast.adjustedForc(1:end,kk),'-.'); 
    set(hand3,'color',color_mat(3,:),'LineWidth',width_mat(3)); 
    hold off
        
    title('All Shocks','FontSize',titfont)
    limvec=limsaj([forecast.allShocksOff(2:end,kk) forecast.adjustedForc(1:end,kk)],0.3); 
    axis tight; 
    set(handsub,'box','off')
    xlim([xaxis(1)-0.05 xaxis(end)+0.05]) 
    set(gca,'XTick',xaxis)
    set(gca,'XTickLabel',xaxis_labels)
    %ylim(limvec); 
    hand4=vline(xaxis(2));
    set(hand4,'Color','g','LineWidth',2,'LineStyle','--');
    
    set(gvec_Shockcont(kk),'PaperPosition',[0.75 0.5 7.5 10])
    
    handleg=legend([200 12 0.8 0.8],barlegends,'orientation','horizontal','FontSize',10);
    set(handleg,'Box','Off');
    
    handtit=suptitle(forcStru.labels{kk},titfont+1);
    set(handtit,'FontWeight','Bold');
    
end

for i1 = 1:length(tastyRecipe)
    print(tastyRecipe(i1),'-dpsc',fullfile(setStru.savePath,'Conditional Forecasts'),'-append');
end
